const { defineConfig, webpack } = require("webpack-common");
const { VueLoaderPlugin } = require("vue-loader");
const TinyfyPlugin = require("webpack-plugin-tinyfy");
const NODE_ENV = process.env.NODE_ENV;

module.exports = defineConfig({
  devServer: {
    open: true,
    port: 4000,
    proxy: [
      {
        context: ["/oao"],
        target: `https://${NODE_ENV}-mobile-api.bankneo.co.id`,
        changeOrigin: true,
        secure: false,
        pathRewrite: {
          "^/oao": "",
        },
      },
    ],
  },
  module: {
    rules: [
      {
        test: /\.vue?$/,
        use: [
          {
            loader: "vue-loader",
          },
        ],
        exclude: /node_modules/,
      },
    ],
  },
  plugins: [
    new webpack.DefinePlugin({
      __VUE_OPTIONS_API__: "true",
      __VUE_PROD_DEVTOOLS__: "false",
      __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "false",
    }),
    new VueLoaderPlugin(),
    new TinyfyPlugin(),
  ],
});
